package uy.com.tsi2G7.superbet.ui;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

import uy.com.tsi2G7.superbet.integration.betfair.rss.Feed;
import uy.com.tsi2G7.superbet.integration.betfair.rss.RSSFeedParser;

@ManagedBean(name = "rSSBetFirBean")
@ViewScoped
public class RSSBetFirBean {
	
	@ManagedProperty(value="#{panelMenuBean}")
	private PanelMenuBean panelMenuBean;
	
	
	
	public PanelMenuBean getPanelMenuBean() {
		return panelMenuBean;
	}



	public void setPanelMenuBean(PanelMenuBean panelMenuBean) {
		this.panelMenuBean = panelMenuBean;
	}



	public List<Feed> getLastResults(){
		
		List<Feed> res=new ArrayList<Feed>();
		for (MenuDescriptor menu : panelMenuBean.getGroups()) {
			RSSFeedParser parser = new RSSFeedParser(
				"http://rss.betfair.com/RSS.aspx?format=rss&sportID="+menu.getId().longValue());
			res.add(parser.readFeed());
		}
		return res;
	}
	
	

}
